//
//  SecMCollectionViewCell.m
//  W2MD
//
//  Created by 海明洋 on 2/8/15.
//  Copyright (c) 2015 zhudongwei. All rights reserved.
//

#import "SecMCollectionViewCell.h"

@implementation SecMCollectionViewCell
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self != nil)
    {
        // create our image view so that is matches the height and width of this cell
        _imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.width)];
        self.imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        self.imageView.contentMode = UIViewContentModeScaleAspectFill;
        self.imageView.clipsToBounds = YES;
        
        // add a white frame around the image
        //self.imageView.layer.borderWidth = 1.0;
        self.imageView.layer.borderColor = [UIColor blackColor].CGColor;
        
        // Define how the edges of the layer are rasterized for each of the four edges
        // (left, right, bottom, top) if the corresponding bit is set the edge will be antialiased
        //
        self.imageView.layer.edgeAntialiasingMask =
        kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge;
        
        _titleName = [[UILabel alloc] initWithFrame:CGRectMake(0, self.bounds.size.height+5, self.bounds.size.width, 16)];
        _titleName.textColor = [UIColor colorWithRed:162.f/255.f green:103.f/255.f blue:215.f/255.f alpha:1.f];
        _titleName.font = [UIFont boldSystemFontOfSize:10.f];
        _titleName.textAlignment = NSTextAlignmentCenter;
        //_titleName.backgroundColor=[UIColor redColor];
        
        [[self contentView] addSubview:self.imageView];
        [[self contentView] addSubview:self.titleName];
        
        _checkIV = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.size.width-13-6, 6, 13, 13)];
        self.checkIV.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        self.checkIV.contentMode = UIViewContentModeScaleAspectFill;
        self.checkIV.clipsToBounds = YES;
        self.checkIV.layer.borderColor = [UIColor whiteColor].CGColor;
        self.checkIV.layer.edgeAntialiasingMask =
        kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge;
        [self.checkIV setImage:[UIImage imageNamed:@"home_check.png"]];
        [[self contentView] addSubview:self.checkIV];
    }
    return self;
}
@end
